#!/opt/apps/python3/bin/python3

import sys

from datetime import datetime
import pytz
tz = pytz.timezone
datetime.now(tz)


sys.path.append("/opt/apps/openGauss/lib/python3.5/site-packages")




import psycopg2

def test():
    host = '127.0.0.1'
    user = 'test'
    pwd = 'test'
    port = 5432
    table = 'test'
    database = 'postgres'
    SQL_TIMEOUT = 30
    dbtype = 1

    sql_conn = psycopg2.connect(host=host, port=port, user=user, password=pwd, database=database, connect_timeout=SQL_TIMEOUT)
    cursor = sql_conn.cursor()


    def get_data():
        cursor.execute("SELECT * from information_schema.tables where table_name='{table}';".format(table=table))
        count = cursor.rowcount
        print("get data len is : {}".format(count))
        if count == 0:
            cursor.execute("CREATE TABLE {table} (emp_first_name text, emp_last_name text, emp_salary numeric)".format(table=table))
            sql_conn.commit()
        else:
            one_data = cursor.fetchone()

            print(one_data)


















